home *** CD-ROM | disk | FTP | other *** search
- rem $title:'Indexing routines & test program.'
- rem $subtitle:'Test / Calling program'
- rem $include:'aecommon.bas'
-
- def fntdiff%(a$,b$)
- k%=val(mid$(a$,4,2))*60+val(mid$(a$,7,2))
- k%=k%-(val(mid$(b$,4,2))*60+val(mid$(b$,7,2)))
- fntdiff%=abs(k%)
- end def
-
- print
- print "Driver to test the btree routines."
- print "(c) Roy Barrow, 1987. version 2.08."
- print
- menu:
- fl%=1%
- print " 1....create"
- print " 2....open"
- print " 3....close"
- print " 4....insert"
- print " 5....delete"
- print " 6....next in sequence"
- print " 7....find"
- print " 9....previous in sequence"
- print " 10...list in forward sequence"
- print " 11...mass input of keys"
- print " 12...automated mass input from file words.dat"
- print
- print "Index:";ixn$;" Next=";xh%(fl%,3);"Next Del=";xh%(fl%,4);"No Keys=";xh%(fl%,2)
-
- input op$
- op%=val(op$)
- if op%=0 then goto fini
- if op%<1 or op%>12 then goto menu
- on op% goto create,opfile,clfile,infile,delfile,nxsseq,nfind,dump,prev,fseq,massin,aumass
- goto menu
-
- create:
- call bit.creat
- goto menu
-
- opfile:
- print "opening index"
- line input "enter index name: ",ixn$
- if ixn$="" then print "no index name / open index !":goto menu
- call bit.open(fl%,ixn$)
- if aesb.fatal% then
- print "error opening index."
- end
- end if
- print "keylength =";xh%(fl%,1)
- print "next avail =";xh%(fl%,3)
- goto menu
-
- infile:
- if ixn$="" then print "no index name / open index !":goto menu
- input "enter key to insert: ",kin$
- input "enter num for master record: ",acc%
- call bit.ins(fl%,kin$,acc%,what%)
- if what%=1 then print "succeeded" else print "failed"
- goto menu
-
- delfile:
- if ixn$="" then print "no index name / open index !":goto menu
- input "enter key to delete: ",kin$
- call bit.find(fl%,kin$,acc%,what%)
- if acc%=0 then print "not there.":goto menu
- if acc%<0 then print "closest match:";kin$:goto menu
- print kin$;" found at record";acc%
- call bit.kill(fl%,kin$,acc%,what%)
- if what%=1 then print "succeeded" else print "failed"
- goto menu
-
- clfile:
- if ixn$="" then print "no index name / open index !":goto menu
- call bit.close(fl%)
- ixn$="" ' just to say none open!
- goto menu
-
- nfind:
- if ixn$="" then print "no index name / open index !":goto menu
- input "key to search for:",kin$
- call bit.find(fl%,kin$,acc%,what%)
- if acc%=0 then print "not there.":goto menu
- if acc%<0 then print "closest match:";kin$:goto menu
- print kin$;" found at record";acc%
- goto menu
-
- nxsseq:
- if ixn$="" then print "no index name / open index !":goto menu
- ktmp$=kin$
- call bit.next(fl%,kin$,acc%,what%)
- if acc%=0% and what%=0% then
- print "No next record,";ktmp$;" probably the end (if legal)"
- kin$=ktmp$
- call bit.find(fl%,kin$,acc%,what%)
- else
- print kin$;" is result"
- end if
- goto menu
-
- fseq:
- if ixn$="" then print "no index name / open index !":goto menu
- call bit.left(fl%,kin$,acc%,what%)
- print kin$;" ";
- pacc%=0%
- while acc%<>pacc%
- pacc%=acc%
- call bit.next(fl%,kin$,acc%,what%)
- print kin$;" ";
- wend
- print
- goto menu
-
- dump:
- goto menu
-
- fini:
- if ixn$="" then end
- call bit.close(fl%)
- end
-
- prev:
- if ixn$="" then print "no index name / open index !":goto menu
- ktmp$=kin$
- call bit.prev(fl%,kin$,acc%,what%)
- if acc%=0% and what%=0% then
- print "No previous record,";ktmp$;" probably the end (if legal)"
- kin$=ktmp$
- call bit.find(fl%,kin$,acc%,what%)
- else
- print kin$;" is result"
- end if
- goto menu
-
-
- massin:
- if ixn$="" then print "no index name / open index !":goto menu
- input "start record: ";acc%
- nmass:
- input "enter key to insert: ",kin$
- if kin$="" then goto menu
- call bit.ins(fl%,kin$,acc%,what%)
- if what%=1 then print "succeeded" else print "failed"
- acc%=acc%+1
- goto nmass
-
- aumass:
- cls
- if ixn$="" then print "no index name / open index !":goto menu
- open "words.dat" for input as #5
- acc%=1
- pl%=10
- ph%=0
- tmass:
- what%=1%
- while not eof(5) and what%=1%
- line input #5,ky$
- print ky$;acc%
- kin$=ky$
- if kin$="" then goto null
- e$=time$
- call bit.ins(fl%,kin$,acc%,what%)
- f$=time$
- th%=fntdiff%(e$,f$)
- av!=av!+th%
- if th%<pl% then pl%=th%
- if th%>ph% then ph%=th%
- if what%=1 then
- kp$=ky$+str$(xh%(fl%,3))+" "+str$(av!/acc%)
- if len(kp$)<70% then
- kp$=kp$+string$(70%-len(kp$),32%)
- ' call qprint(kp$,6%,1%)
- end if
- acc%=acc%+1
- end if
- null:
- wend
- close 5
- goto menu
-
-
-